home *** CD-ROM | disk | FTP | other *** search
- From: Tom Truscott <decvax!mcnc!rti-sel!trt>
- Subject: wm (part 4 of 4) - Patches to Curses
- Newsgroups: mod.sources
- Approved: john@genrad.UUCP
-
- Mod.sources: Volume 2, Issue 34
- Submitted by: Tom Truscott <decvax!mcnc!rti-sel!trt>
-
-
- #! /bin/sh
- # This is a shell archive, meaning:
- # 1. Remove everything above the #! /bin/sh line.
- # 2. Save the resulting text in a file.
- # 3. Execute the file with /bin/sh (not csh) to create the files:
- # README.curses
- # UPGRADE
- # addch.c.pat
- # clrtobot.c.pat
- # cr_tty.c.pat
- # curses.h.new
- # deleteln.c.pat
- # initscr.c.pat
- # insertln.c.pat
- # longname.c.new
- # move.c.pat
- # mvwin.c.pat
- # newwin.c.pat
- # overlay.c.pat
- # printw.c.new
- # refresh.c.pat
- # tstp.c.new
- # This archive created: Fri Aug 2 13:33:10 1985
- export PATH; PATH=/bin:$PATH
- echo shar: extracting "'README.curses'" '(1005 characters)'
- if test -f 'README.curses'
- then
- echo shar: will not over-write existing file "'README.curses'"
- else
- sed 's/^X//' << \SHAR_EOF > 'README.curses'
- XSAVE THIS KIT IF YOU WANT TO RUN THE 'WM' WINDOW MANAGER
-
- 4.2 BSD libcurses patch kit
- Tom Truscott, mcnc!rti-sel!trt
- Research Triangle Institute, NC
- (919) 541-7005
-
- This is a collection of patches
- for the vanilla 4.2 BSD libcurses distribution.
- It includes some bug fixes reported on Usenet,
- some discovered locally, and some (but not all) of
- the fixes in the UCSF User Software Engineering distribution ("Troll").
- Tony Wassermann graciously permitted those to be included here.
-
- It also includes some disgusting efficiency hacks.
-
- To Install:
- *) Unpack this shar file in an empty directory.
- *) In 'UPGRADE', set the CURSRC variable to
- the name of the *vanilla* 4.2 BSD libcurses sources.
- *) Make sure you have the wonderful 'patch' program.
- (If you do not, do the patches yourself!)
- *) Run UPGRADE
- *) 'make' to compile libcurses and libcurses_p
- *) If you want to install this as the standard curses,
- a) save the old curses.h and /usr/lib/libcur*
- b) 'make install'
- c) cp curses.h /usr/include
- SHAR_EOF
- if test 1005 -ne "`wc -c < 'README.curses'`"
- then
- echo shar: error transmitting "'README.curses'" '(should have been 1005 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'UPGRADE'" '(573 characters)'
- if test -f 'UPGRADE'
- then
- echo shar: will not over-write existing file "'UPGRADE'"
- else
- sed 's/^X//' << \SHAR_EOF > 'UPGRADE'
- #! /bin/sh
- CURSRC=/usr/src/usr.lib/libcurses
-
- echo 'Copying in the 4.2 BSD libcurses'
- (cd $CURSRC; tar cf - .) | tar xvpf -
-
- echo 'Replacing modules:'
- for i in *.new
- do
- echo " $i"
- mv `basename $i .new` `basename $i .new`.orig
- cp $i `basename $i .new`
- done
- echo ' '
-
- echo 'Patching modules:'
- for i in *.pat
- do
- echo " $i"
- patch `basename $i .pat` $i
- done
- echo ' '
-
- echo 'Done'
-
- echo 'To compile, "make"'
- echo 'To install, "make install"'
- echo '(But first save the old /usr/include/curses.h and /usr/lib/libcurs*)'
- echo 'To clean up, "make clean; rm *.orig *.new *.pat"'
- SHAR_EOF
- if test 573 -ne "`wc -c < 'UPGRADE'`"
- then
- echo shar: error transmitting "'UPGRADE'" '(should have been 573 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'addch.c.pat'" '(1025 characters)'
- if test -f 'addch.c.pat'
- then
- echo shar: will not over-write existing file "'addch.c.pat'"
- else
- sed 's/^X//' << \SHAR_EOF > 'addch.c.pat'
- *** libcurses42/addch.c Thu Nov 17 11:03:10 1983
- --- libcurses/addch.c Wed Jul 24 13:30:58 1985
- ***************
- *** 19,22
- # endif
- ! if (y >= win->_maxy || x >= win->_maxx || y < 0 || x < 0)
- ! return ERR;
- switch (c) {
-
- --- 19,25 -----
- # endif
- ! #ifdef slowway
- ! /* These tests 'cannot happen'. What about win==NULL?! */
- ! if (y < 0 || y >= win->_maxy || x < 0 || x >= win->_maxx)
- ! return (ERR);
- ! #endif
- switch (c) {
- ***************
- *** 38,40
- c |= _STANDOUT;
- ! set_ch(win, y, x, c, NULL);
- for (wp = win->_nextp; wp != win; wp = wp->_nextp)
-
- --- 41,55 -----
- c |= _STANDOUT;
- ! #ifdef slowway
- ! set_ch(win, y, x, c, (WINDOW *)NULL);
- ! #else
- ! /* rti-sel!trt: efficiency hack */
- ! if (win->_y[y][x] != c) {
- ! if (win->_firstch[y] == _NOCHANGE)
- ! win->_firstch[y] = win->_lastch[y] = x;
- ! else if (x > win->_lastch[y])
- ! win->_lastch[y] = x;
- ! else if (x < win->_firstch[y])
- ! win->_firstch[y] = x;
- ! }
- ! #endif
- for (wp = win->_nextp; wp != win; wp = wp->_nextp)
- SHAR_EOF
- if test 1025 -ne "`wc -c < 'addch.c.pat'`"
- then
- echo shar: error transmitting "'addch.c.pat'" '(should have been 1025 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'clrtobot.c.pat'" '(500 characters)'
- if test -f 'clrtobot.c.pat'
- then
- echo shar: will not over-write existing file "'clrtobot.c.pat'"
- else
- sed 's/^X//' << \SHAR_EOF > 'clrtobot.c.pat'
- *** libcurses42/clrtobot.c Thu Nov 17 11:03:12 1983
- --- libcurses/clrtobot.c Wed Jul 24 13:29:44 1985
- ***************
- *** 3,5
- /*
- ! * This routine erases everything on the window.
- *
-
- --- 3,7 -----
- /*
- ! * This routine erases from the current position
- ! * to the end of the window (inclusive).
- ! * The current position remains unchanged.
- *
- ***************
- *** 34,36
- }
- ! win->_curx = win->_cury = 0;
- }
-
- --- 36,40 -----
- }
- ! #ifdef wantamess
- ! win->_curx=win->_cury=0;
- ! #endif
- }
- SHAR_EOF
- if test 500 -ne "`wc -c < 'clrtobot.c.pat'`"
- then
- echo shar: error transmitting "'clrtobot.c.pat'" '(should have been 500 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'cr_tty.c.pat'" '(339 characters)'
- if test -f 'cr_tty.c.pat'
- then
- echo shar: will not over-write existing file "'cr_tty.c.pat'"
- else
- sed 's/^X//' << \SHAR_EOF > 'cr_tty.c.pat'
- *** libcurses42/cr_tty.c Thu Nov 17 11:02:54 1983
- --- libcurses/cr_tty.c Thu Mar 14 13:31:45 1985
- ***************
- *** 96,98
- PC = xPC ? xPC[0] : FALSE;
- ! aoftspace = tspace;
- strcpy(ttytype, longname(genbuf, type));
-
- --- 96,98 -----
- PC = xPC ? xPC[0] : FALSE;
- ! /* aoftspace = tspace;*/
- strcpy(ttytype, longname(genbuf, type));
- SHAR_EOF
- if test 339 -ne "`wc -c < 'cr_tty.c.pat'`"
- then
- echo shar: error transmitting "'cr_tty.c.pat'" '(should have been 339 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'curses.h.new'" '(4778 characters)'
- if test -f 'curses.h.new'
- then
- echo shar: will not over-write existing file "'curses.h.new'"
- else
- sed 's/^X//' << \SHAR_EOF > 'curses.h.new'
- /* @(#)curses.h 1.14 (Berkeley) 7/4/83 */
- /* Dec 83 Corrections made at University of California, San Francisco */
- # ifndef WINDOW
-
- # include <stdio.h>
-
- # include <sgtty.h>
- # include <sys/ioctl.h>
-
- # define bool char
- # define reg register
-
- # define TRUE (1)
- # define FALSE (0)
- # define ERR (0)
- # define OK (1)
-
- # define _ENDLINE 001
- # define _FULLWIN 002
- # define _SCROLLWIN 004
- # define _FLUSH 010
- # define _STANDOUT 0200
- # define _NOCHANGE -1
-
- # define _puts(s) tputs(s, 0, _putchar)
-
- typedef struct sgttyb SGTTY;
-
- /*
- * Capabilities from termcap
- */
-
- extern bool AM, BS, CA, DA, DB, EO, GT, HZ, IN, MI, MS, NC, OS, UL,
- XN;
- extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *DC, *DL, *DM,
- *DO, *ED, *EI, *HO, *IC, *IM, *IP, *LL, *MA, *ND, *NL,
- *SE, *SF, *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US,
- *VB, *VE, *VS, PC;
-
- /*
- * From the tty modes...
- */
-
- extern bool NONL, UPPERCASE, normtty, _pfast;
-
- struct _win_st {
- short _cury, _curx;
- short _maxy, _maxx;
- short _begy, _begx;
- short _flags;
- bool _clear;
- bool _leave;
- bool _scroll;
- char **_y;
- short *_firstch;
- short *_lastch;
- struct _win_st *_nextp, *_orig;
- };
-
- # define WINDOW struct _win_st
-
- extern bool My_term, _echoit, _rawmode, _endwin;
-
- extern char *Def_term, ttytype[];
-
- extern int LINES, COLS, _tty_ch, _res_flg;
-
- extern SGTTY _tty;
-
- extern WINDOW *stdscr, *curscr;
-
- /*
- * Define VOID to stop lint from generating "null effect"
- * comments.
- */
- # ifdef lint
- int __void__;
- # define VOID(x) (__void__ = (int) (x))
- # else
- # define VOID(x) (x)
- # endif
-
- /*
- * psuedo functions for standard screen
- */
- # define addch(ch) VOID(waddch(stdscr, ch))
- # define getch() VOID(wgetch(stdscr))
- # define addstr(str) VOID(waddstr(stdscr, str))
- # define getstr(str) VOID(wgetstr(stdscr, str))
- # define move(y, x) VOID(wmove(stdscr, y, x))
- # define clear() VOID(wclear(stdscr))
- # define erase() VOID(werase(stdscr))
- # define clrtobot() VOID(wclrtobot(stdscr))
- # define clrtoeol() VOID(wclrtoeol(stdscr))
- # define insertln() VOID(winsertln(stdscr))
- # define deleteln() VOID(wdeleteln(stdscr))
- # define refresh() VOID(wrefresh(stdscr))
- # define inch() VOID(winch(stdscr))
- # define insch(c) VOID(winsch(stdscr,c))
- # define delch() VOID(wdelch(stdscr))
- # define standout() VOID(wstandout(stdscr))
- # define standend() VOID(wstandend(stdscr))
-
- /*
- * mv functions
- */
- #define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
- #define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
- #define mvwaddstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
- #define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
- #define mvwinch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
- #define mvwdelch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win))
- #define mvwinsch(win,y,x,c) VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c))
- #define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
- #define mvgetch(y,x) mvwgetch(stdscr,y,x)
- #define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str)
- #define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str)
- #define mvinch(y,x) mvwinch(stdscr,y,x)
- #define mvdelch(y,x) mvwdelch(stdscr,y,x)
- #define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c)
-
- /*
- * psuedo functions
- */
-
- #define clearok(win,bf) (win->_clear = bf)
- #define leaveok(win,bf) (win->_leave = bf)
- #define scrollok(win,bf) (win->_scroll = bf)
- #define flushok(win,bf) (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
- #define getyx(win,y,x) y = win->_cury, x = win->_curx
- #define winch(win) (win->_y[win->_cury][win->_curx] & 0177)
-
- #define raw() (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
- #define noraw() (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
- #define crmode() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
- #define nocrmode() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
- #define echo() (_tty.sg_flags |= ECHO, _echoit = TRUE, ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
- #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
- /* nl(), nonl() fixed by Mike Lilley and Mike Laman */
- #define nl() (_tty.sg_flags |= CRMOD,_pfast = _tty.sg_flags&RAW,NONL=FALSE,ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
- #define nonl() (_tty.sg_flags &= ~CRMOD, _pfast = TRUE,NONL=TRUE, ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
- #define savetty() ((void)gtty(_tty_ch,&_tty), _res_flg = _tty.sg_flags)
- #define resetty() (_tty.sg_flags = _res_flg, ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
-
- WINDOW *initscr(), *newwin(), *subwin();
- char *longname(), *getcap();
-
- /*
- * Used to be in unctrl.h.
- */
- #define unctrl(c) _unctrl[(c) & 0177]
- extern char *_unctrl[];
- # endif
- SHAR_EOF
- if test 4778 -ne "`wc -c < 'curses.h.new'`"
- then
- echo shar: error transmitting "'curses.h.new'" '(should have been 4778 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'deleteln.c.pat'" '(361 characters)'
- if test -f 'deleteln.c.pat'
- then
- echo shar: will not over-write existing file "'deleteln.c.pat'"
- else
- sed 's/^X//' << \SHAR_EOF > 'deleteln.c.pat'
- *** libcurses42/deleteln.c Thu Nov 17 11:02:56 1983
- --- libcurses/deleteln.c Sat Jul 6 14:14:20 1985
- ***************
- *** 24,25
- win->_y[win->_maxy-1] = temp - win->_maxx;
- }
-
- --- 24,27 -----
- win->_y[win->_maxy-1] = temp - win->_maxx;
- + win->_firstch[win->_maxy-1] = 0; /* Mike Laman (?) */
- + win->_lastch[win->_maxy-1] = win->_maxx -1; /* ditto */
- }
- SHAR_EOF
- if test 361 -ne "`wc -c < 'deleteln.c.pat'`"
- then
- echo shar: error transmitting "'deleteln.c.pat'" '(should have been 361 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'initscr.c.pat'" '(485 characters)'
- if test -f 'initscr.c.pat'
- then
- echo shar: will not over-write existing file "'initscr.c.pat'"
- else
- sed 's/^X//' << \SHAR_EOF > 'initscr.c.pat'
- *** libcurses42/initscr.c Thu Nov 17 11:03:00 1983
- --- libcurses/initscr.c Sun Jul 21 17:59:02 1985
- ***************
- *** 15,16
- reg char *sp;
- int tstp();
-
- --- 15,17 -----
- reg char *sp;
- + int (*oldtstp)(); /* Ron Wessels, uthub.149, May 1984 */
- int tstp();
- ***************
- *** 41,43
- # ifdef SIGTSTP
- ! signal(SIGTSTP, tstp);
- # endif
-
- --- 42,45 -----
- # ifdef SIGTSTP
- ! if ((oldtstp = signal(SIGTSTP, tstp)) != SIG_DFL)
- ! (void) signal(SIGTSTP, oldtstp);
- # endif
- SHAR_EOF
- if test 485 -ne "`wc -c < 'initscr.c.pat'`"
- then
- echo shar: error transmitting "'initscr.c.pat'" '(should have been 485 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'insertln.c.pat'" '(242 characters)'
- if test -f 'insertln.c.pat'
- then
- echo shar: will not over-write existing file "'insertln.c.pat'"
- else
- sed 's/^X//' << \SHAR_EOF > 'insertln.c.pat'
- *** libcurses42/insertln.c Thu Nov 17 11:03:01 1983
- --- libcurses/insertln.c Sat Jul 6 14:12:54 1985
- ***************
- *** 34,35
- return ERR;
- return OK;
-
- --- 34,36 -----
- return ERR;
- + touchwin(win); /* Mike Laman */
- return OK;
- SHAR_EOF
- if test 242 -ne "`wc -c < 'insertln.c.pat'`"
- then
- echo shar: error transmitting "'insertln.c.pat'" '(should have been 242 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'longname.c.new'" '(855 characters)'
- if test -f 'longname.c.new'
- then
- echo shar: will not over-write existing file "'longname.c.new'"
- else
- sed 's/^X//' << \SHAR_EOF > 'longname.c.new'
- # define reg register
-
- /*
- * This routine fills in "def" with the long name of the terminal.
- *
- * 1/26/81 (Berkeley) @(#)longname.c 1.1
- *
- * 2/22/84 Corrections made at University of California, San Francisco.
- * This correction makes a private copy of the longname. The original version
- * simply patched a '\0' in the termcap buffer, preventing access to
- * terminal capabilities at a later point.
- * rti-sel!trt: note: this code is still broken wrt the documentation.
- * It operates confusingly and usually gets the wrong answer.
- */
-
- char *
- longname(bp, def)
- reg char *bp, *def; {
-
- reg char *cp;
- static char longcopy[30] ;
-
- while (*bp && *bp != ':' && *bp != '|')
- bp++;
- if (*bp == '|') {
- bp++;
- cp = longcopy ;
- while ((cp-longcopy)<29 && *bp && *bp != ':' && *bp != '|')
- *cp++ = *bp++ ;
- *cp = 0;
- return longcopy;
- }
- return def;
- }
- SHAR_EOF
- if test 855 -ne "`wc -c < 'longname.c.new'`"
- then
- echo shar: error transmitting "'longname.c.new'" '(should have been 855 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'move.c.pat'" '(312 characters)'
- if test -f 'move.c.pat'
- then
- echo shar: will not over-write existing file "'move.c.pat'"
- else
- sed 's/^X//' << \SHAR_EOF > 'move.c.pat'
- *** libcurses42/move.c Thu Nov 17 11:03:14 1983
- --- libcurses/move.c Wed Jul 24 13:25:47 1985
- ***************
- *** 14,15
- # endif
- if (x >= win->_maxx || y >= win->_maxy)
-
- --- 14,19 -----
- # endif
- + #ifndef wantamess
- + if (x < 0 || y < 0)
- + return(ERR);
- + #endif
- if (x >= win->_maxx || y >= win->_maxy)
- SHAR_EOF
- if test 312 -ne "`wc -c < 'move.c.pat'`"
- then
- echo shar: error transmitting "'move.c.pat'" '(should have been 312 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'mvwin.c.pat'" '(309 characters)'
- if test -f 'mvwin.c.pat'
- then
- echo shar: will not over-write existing file "'mvwin.c.pat'"
- else
- sed 's/^X//' << \SHAR_EOF > 'mvwin.c.pat'
- *** libcurses42/mvwin.c Thu Nov 17 11:03:03 1983
- --- libcurses/mvwin.c Wed May 30 22:23:12 1984
- ***************
- *** 12,14
-
- ! if (by + win->_maxy > LINES || bx + win->_maxx > COLS)
- return ERR;
-
- --- 12,14 -----
-
- ! if (by + win->_maxy > LINES || bx + win->_maxx > COLS || by<0 || bx<0)
- return ERR;
- SHAR_EOF
- if test 309 -ne "`wc -c < 'mvwin.c.pat'`"
- then
- echo shar: error transmitting "'mvwin.c.pat'" '(should have been 309 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'newwin.c.pat'" '(336 characters)'
- if test -f 'newwin.c.pat'
- then
- echo shar: will not over-write existing file "'newwin.c.pat'"
- else
- sed 's/^X//' << \SHAR_EOF > 'newwin.c.pat'
- *** libcurses42/newwin.c Thu Nov 17 11:03:02 1983
- --- libcurses/newwin.c Wed Jul 24 13:27:23 1985
- ***************
- *** 117,118
-
- # ifdef DEBUG
-
- --- 117,125 -----
-
- + #ifndef wantamess
- + if (by < 0 || bx < 0 || nl <= 0 || nc <= 0)
- + return(NULL);
- + if (by+nl > LINES || bx+nc > COLS)
- + return(NULL);
- + #endif
- +
- # ifdef DEBUG
- SHAR_EOF
- if test 336 -ne "`wc -c < 'newwin.c.pat'`"
- then
- echo shar: error transmitting "'newwin.c.pat'" '(should have been 336 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'overlay.c.pat'" '(413 characters)'
- if test -f 'overlay.c.pat'
- then
- echo shar: will not over-write existing file "'overlay.c.pat'"
- else
- sed 's/^X//' << \SHAR_EOF > 'overlay.c.pat'
- *** libcurses42/overlay.c Thu Nov 17 11:03:04 1983
- --- libcurses/overlay.c Sat Jul 6 14:13:04 1985
- ***************
- *** 24,26
- endx = min(win1->_maxx, win2->_maxx) - win1->_begx - 1;
- ! for (y = starty; y < endy; y++) {
- end = &win1->_y[y][endx];
-
- --- 24,26 -----
- endx = min(win1->_maxx, win2->_maxx) - win1->_begx - 1;
- ! for (y = starty; y <= endy; y++) { /* Mike Laman */
- end = &win1->_y[y][endx];
- SHAR_EOF
- if test 413 -ne "`wc -c < 'overlay.c.pat'`"
- then
- echo shar: error transmitting "'overlay.c.pat'" '(should have been 413 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'printw.c.new'" '(1849 characters)'
- if test -f 'printw.c.new'
- then
- echo shar: will not over-write existing file "'printw.c.new'"
- else
- sed 's/^X//' << \SHAR_EOF > 'printw.c.new'
- /*
- * printw and friends
- *
- * 1/26/81 (Berkeley) @(#)printw.c 1.1
- */
-
- # include "curses.ext"
-
- /*
- * This routine implements a printf on the standard screen.
- *
- * Modified by David Owen, U.C.S.D. 10.5.83 to allow arbitrary
- * length strings to "printw". In "sprintw" the error status is
- * checked on return from the "doprnt" and if set, the
- * call is repeated with a bigger buffer.
- */
- printw(fmt, args)
- char *fmt;
- int args; {
-
- return _sprintw(stdscr, fmt, &args);
- }
-
- /*
- * This routine implements a printf on the given window.
- */
- wprintw(win, fmt, args)
- WINDOW *win;
- char *fmt;
- int args; {
-
- return _sprintw(win, fmt, &args);
- }
- /*
- * This routine actually executes the printf and adds it to the window
- *
- * This is really a modified version of "sprintf". As such,
- * it assumes that sprintf interfaces with the other printf functions
- * in a certain way. If this is not how your system works, you
- * will have to modify this routine to use the interface that your
- * "sprintf" uses.
- */
- _sprintw(win, fmt, args)
- WINDOW *win;
- char *fmt;
- int *args; {
-
- FILE junk;
- char buf[BUFSIZ],*bptr;
- int count,res;
- count = 0;
-
- junk._flag = _IOWRT + _IOSTRG;
- junk._ptr = buf;
- junk._base = buf;
- junk._cnt = BUFSIZ;
- /*Make sure error flag set if ever "flsbuf" is called*/
- junk._file = -1;
- for(;;){
- _doprnt(fmt, args, &junk);
- putc('\0', &junk);
- /*If there was a write error increase buffer and try again*/
- if(junk._flag & _IOERR){
- if(count)
- free(bptr);
- else
- count = BUFSIZ;
- count += BUFSIZ;
- if((bptr = (char *)malloc(count)) == NULL){
- fprintf(stderr,"sprintw:no malloc space\n");
- return(-1);
- }
- junk._flag = _IOWRT + _IOSTRG;
- junk._ptr = bptr;
- junk._base = bptr;
- junk._cnt = count;
- junk._file = -1;
- continue;
- }
- res = waddstr(win,junk._base);
- if(count) free(bptr);
- return(res);
- }
- }
-
- SHAR_EOF
- if test 1849 -ne "`wc -c < 'printw.c.new'`"
- then
- echo shar: error transmitting "'printw.c.new'" '(should have been 1849 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'refresh.c.pat'" '(4884 characters)'
- if test -f 'refresh.c.pat'
- then
- echo shar: will not over-write existing file "'refresh.c.pat'"
- else
- sed 's/^X//' << \SHAR_EOF > 'refresh.c.pat'
- *** libcurses42/refresh.c Thu Nov 17 11:03:06 1983
- --- libcurses/refresh.c Tue Jul 30 23:16:01 1985
- ***************
- *** 5,6
- * 5/12/83 (Berkeley) @(#)refresh.c 1.8
- */
-
- --- 5,14 -----
- * 5/12/83 (Berkeley) @(#)refresh.c 1.8
- + *
- + * 2/28/84 Correction at UCSF:
- + * Take the terminal out of standout mode, before clear to end of line
- + * if it isn't safe to move in standout mode (termcap entry ms)
- + *
- + * 3/14/85 Corrections at RTI
- + * Fix problems reported on Usenet. Also, delete apparently
- + * useless (and harmful) code if _leave has been set.
- */
- ***************
- *** 86,87
- curscr->_curx = lx;
- ly -= win->_begy;
-
- --- 94,97 -----
- curscr->_curx = lx;
- + #ifdef wantamess
- + /* rti-sel!trt: this code is completely bogus, yes? */
- ly -= win->_begy;
- ***************
- *** 94,95
- win->_cury = win->_curx = 0;
- }
-
- --- 104,106 -----
- win->_cury = win->_curx = 0;
- + #endif
- }
- ***************
- *** 118,119
- reg int nlsp, clsp; /* last space in lines */
-
-
- --- 129,131 -----
- reg int nlsp, clsp; /* last space in lines */
- + static int glitchXN;
-
- ***************
- *** 128,129
- if (CE && !curwin) {
- for (ce = &win->_y[wy][win->_maxx - 1]; *ce == ' '; ce--)
-
- --- 140,142 -----
- if (CE && !curwin) {
- + #ifdef slowway
- for (ce = &win->_y[wy][win->_maxx - 1]; *ce == ' '; ce--)
- ***************
- *** 132,133
- nlsp = ce - win->_y[wy];
- }
-
- --- 145,149 -----
- nlsp = ce - win->_y[wy];
- + #else
- + nlsp = -1;
- + #endif
- }
- ***************
- *** 139,140
- if (*nsp != *csp) {
- domvcur(ly, lx, y, wx + win->_begx);
-
- --- 155,168 -----
- if (*nsp != *csp) {
- + #ifndef wantamess
- + /* this is no guarantee, but seems to work */
- + if (glitchXN && wx && wx+win->_begx==COLS-1) {
- + domvcur(ly, lx, y, wx+win->_begx-1);
- + ly = y;
- + lx = wx+win->_begx-1;
- + glitchXN = 0;
- + continue;
- + }
- + glitchXN = 0;
- + #endif
- + #ifdef slowway
- domvcur(ly, lx, y, wx + win->_begx);
- ***************
- *** 145,147
- lx = wx + win->_begx;
- ! while (*nsp != *csp && wx <= lch) {
- if (ce != NULL && wx >= nlsp && *nsp == ' ') {
-
- --- 173,212 -----
- lx = wx + win->_begx;
- ! #else
- ! /* speed hacks to avoid domvcur in simple cases */
- ! clsp = wx + win->_begx; /* dirty use of clsp */
- ! if (ly == y) {
- ! if (lx == clsp)
- ! goto at_target;
- ! if (lx+1 == clsp && !curwin) {
- ! /* enter/exit standout mode as appropriate */
- ! if (SO && (csp[-1]&_STANDOUT) != (curscr->_flags&_STANDOUT)) {
- ! if (csp[-1] & _STANDOUT) {
- ! _puts(SO);
- ! curscr->_flags |= _STANDOUT;
- ! }
- ! else {
- ! _puts(SE);
- ! curscr->_flags &= ~_STANDOUT;
- ! }
- ! }
- ! putchar(csp[-1]&0177);
- ! lx++;
- ! goto at_target;
- ! }
- ! if (clsp == 0 && !(curscr->_flags&_STANDOUT)
- ! && !NC && (!CR || CR[1] == '\0')) {
- ! if (CR)
- ! putchar(*CR);
- ! else
- ! putchar('\r');
- ! lx = 0;
- ! goto at_target;
- ! }
- ! }
- ! domvcur(ly, lx, y, clsp);
- ! ly = y;
- ! lx = clsp;
- ! at_target:;
- ! #endif
- ! while (wx <= lch && *nsp != *csp) {
- if (ce != NULL && wx >= nlsp && *nsp == ' ') {
- ***************
- *** 147,148
- if (ce != NULL && wx >= nlsp && *nsp == ' ') {
- /*
-
- --- 212,222 -----
- if (ce != NULL && wx >= nlsp && *nsp == ' ') {
- + #ifndef slowway
- + if (nlsp < 0) {
- + for (nlsp = win->_maxx-1;
- + nlsp > 0 && win->_y[wy][nlsp]==' ';
- + nlsp--)
- + ;
- + continue; /* gotta recheck nlsp */
- + }
- + #endif
- /*
- ***************
- *** 163,164
- # endif
- _puts(CE);
-
- --- 237,245 -----
- # endif
- + /* if we shouldn't move in standout mode, CE may cause
- + problems too
- + */
- + if (curscr->_flags & _STANDOUT && !MS) {
- + _puts(SE);
- + curscr->_flags &= ~_STANDOUT;
- + }
- _puts(CE);
- ***************
- *** 226,228
- else if (wx < lch)
- ! while (*nsp == *csp) {
- nsp++;
-
- --- 307,309 -----
- else if (wx < lch)
- ! while (wx <= lch && *nsp == *csp) {
- nsp++;
- ***************
- *** 239,240
- ret:
- return OK;
-
- --- 320,346 -----
- ret:
- + #ifndef wantamess
- + /* rti-sel!trt: update cursor location on auto-wrap */
- + if (lx >= COLS) {
- + if (XN) { /* make this case like the usual one */
- + if (curscr->_flags & _STANDOUT && !MS) {
- + _puts(SE);
- + curscr->_flags &= ~_STANDOUT;
- + }
- + putchar('\r');
- + putchar('\n');
- + glitchXN++; /* next char must not be in col 80 */
- + }
- + lx = 0;
- + if (ly < LINES-1)
- + ly++;
- + else {
- + /* at this point the current screen scrolled up.
- + * scroll() is strange, so we simulate it by hand.
- + * Curses should probably not put anything in lower
- + * right corner of screen, and thus avoid this mess */
- + wmove(curscr, 0, 0); wdeleteln(curscr);
- + wmove(curscr, ly, lx);
- + }
- + }
- + #endif
- return OK;
- SHAR_EOF
- if test 4884 -ne "`wc -c < 'refresh.c.pat'`"
- then
- echo shar: error transmitting "'refresh.c.pat'" '(should have been 4884 characters)'
- fi
- fi # end of overwriting check
- echo shar: extracting "'tstp.c.new'" '(841 characters)'
- if test -f 'tstp.c.new'
- then
- echo shar: will not over-write existing file "'tstp.c.new'"
- else
- sed 's/^X//' << \SHAR_EOF > 'tstp.c.new'
- # include <signal.h>
-
- # include "curses.ext"
-
- /*
- * handle stop and start signals
- *
- * 6/25/83 (Berkeley) @(#)tstp.c 1.3
- */
- tstp() {
-
- # ifdef SIGTSTP
-
- int ttyflags;
- int omask;
- # ifdef DEBUG
- if (outf)
- fflush(outf);
- # endif
- ttyflags = _tty.sg_flags; /* store curses state */
- mvcur(0, COLS - 1, LINES - 1, 0);
- endwin();
- fflush(stdout);
- /* reset signal handler so kill below stops us */
- signal(SIGTSTP, SIG_DFL);
- #define mask(s) (1 << ((s)-1))
- omask = sigsetmask(sigblock(0) &~ mask(SIGTSTP));
- kill(0, SIGTSTP);
- /* pc stops here */
- /* okay, we started up again. */
- sigsetmask(omask);
- signal(SIGTSTP, tstp);
- savetty(); /* re-remember the virgin state */
- _tty.sg_flags = ttyflags; /* restore special curses state */
- ioctl(_tty_ch, TIOCSETN, &_tty);
- _puts(TI); /* should we do VS too? */
- wrefresh(curscr);
- # endif SIGTSTP
- }
- SHAR_EOF
- if test 841 -ne "`wc -c < 'tstp.c.new'`"
- then
- echo shar: error transmitting "'tstp.c.new'" '(should have been 841 characters)'
- fi
- fi # end of overwriting check
- # End of shell archive
- exit 0
-